#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "kylin-activation.h"
#include "text-i18n.h"

/*
 * kylin_activation_print_result_message, print message according to result number
 */
extern void kylin_activation_print_result_message(int result);

int main(int argc, char** argv)
{
	int result;
	char* qrcode = NULL;

	setlocale(LC_MESSAGES, "");
	bindtextdomain (PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);
	bind_textdomain_codeset(PACKAGE, "utf8");

	if(argc == 1)
	{
		qrcode = kylin_activation_get_qrcode(&result);
	} else if(argc == 2)
	{
		qrcode = kylin_activation_get_qrcode_with_serial(argv[1], &result);
	}
	if(!qrcode || result != NO_ERROR)
	{
		kylin_activation_print_result_message(result);
	}
	else
	{
		if(qrcode)
		{
			printf("%s\n", qrcode);
			free(qrcode);
		}
	}

	exit(result);
}
